package com.tdh.tlgusers.controller;

import com.tdh.tlgusers.pojo.Collect;
import com.tdh.tlgusers.pojo.User;
import com.tdh.tlgusers.service.CollectService;
import com.tdh.tlgusers.service.UserService;
import com.tdh.tlgusers.util.Record;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class UserController {
    @Autowired
    private UserService userService;

    @PostMapping("/register")
    public Record register(@RequestBody User user)  {
        return userService.register(user);
    }

    @GetMapping("/login")
    public Record login(String userName, String password){
          Record record =userService.login(userName,password);
        return record;
    }

    @GetMapping("/selUser")
    public Record selByIdOrUserName(String userName,Integer userId){
        return userService.selByIdOrUserName(userName,userId);
    }

    @GetMapping("/selAllUser")
    public Record selAllUser(){
        return userService.selUsers();
    }

    @PostMapping("/modifyDisable")
    public Record modifyDisable(Integer state,Integer userId){
        return userService.modifyDisable(state,userId);
    }

    @PostMapping("/modifyUserInfo")
    public Record modifyUserInfo(@RequestBody User user){
        return userService.modifyUserInfo(user);
    }
}
